// ==UserScript==
// @name 青书学堂 作业/考试-最新版(千万题库)-秒出答案
// @namespace http://tampermonkey.net/
// @version 2.1
// @description 【注意】如果第一次答题答案不全,可以先查看一遍答案重新答案即可。本脚本包含自动搜集答案功能,请在作业或者考试的时候自觉点击查看答案,方便您下次遇到同样科目便能自动补全答案。若没选的即视为未匹配到正确答案。问题反馈QQ:1012507575
// @author wx:lhy739568808
// @match https://*.qingshuxuetang.com/*/Student/*
// @match https://degree.qingshuxuetang.com/*/Student/ExamPaper*
// @match https://degree.qingshuxuetang.com/*/Student/ExercisePaper*
// @match https://degree.qingshuxuetang.com/*/Student/ViewQuiz*
// @match https://*.qingshuxuetang.com/*/Student/ViewQuiz*
// @require https://lf9-cdn-tos.bytecdntp.com/cdn/expire-10-y/jquery/3.6.0/jquery.min.js
// @require https://update.greasyfork.org/scripts/434540/1065982/layerjs-gm-with-css.js
// @resource layer http://cdn.bootcdn.net/ajax/libs/layer/3.1.1/theme/default/layer.css
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_getResourceText
// @grant GM_getResourceURL
// @grant unsafeWindow
// @connect *
// ==/UserScript==
GM_addStyle(GM_getResourceText('layer'));
GM_addStyle(".site-dir{display:none;}.site-dir li{line-height:26px;overflow:visible;list-style-type:disc;}.site-dir li a{display:block;text-decoration:none}.site-dir li a:active{color:#01AAED;}.site-dir li a.layui-this{color:#01AAED;}body .layui-layer-dir{box-shadow:none;border:1px solid #d2d2d2;}body .layui-layer-dir .layui-layer-content{padding:10px;}.site-dir a em{padding-left:5px;font-size:12px;color:#c2c2c2;font-style:normal;}");
GM_addStyle(".layui-layer-ico16,.layui-layer-loading.layui-layer-loading2{width:32px;height:32px;background:url(https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/theme/default/loading-2.gif)no-repeat;}.layui-layer-ico{background: url(https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/theme/default/icon.png) no-repeat;}");
(function() {
'use strict';
//TOKEN填入此处
var TOKEN = localStorage.getItem("kktoken")
var selfUrl = window.location.href;
var tk = "";
if(TOKEN){tk=TOKEN}
var contentHtml = '
'
+'
'
+' '
+' '
+' '
+' '
+''
+' '
+' '
+' 序号 | '
+' 标题 | '
+' 答案 | '
+'
'
+''
+''
+' '
+'
'
+'
';
if(selfUrl.indexOf("sIndex")>=0||selfUrl.indexOf("ExamPaper")>=0||selfUrl.indexOf("ExercisePaper")>=0){
layer.open({
type: 1,
title:'FASTK - 青书学堂/作业/期末考试',
skin: 'layui-layer-rim', //加上边框
shade: false,
area: ['420px', '700px'], //宽高
closeBtn: 1,
maxmin: true,
content: contentHtml
});
}
setTimeout(function(){
var questions = $(".question-detail-container")
for(var i=0;i=0||ttt.indexOf("简答题")>=0||ttt.indexOf("填空")>=0||ttt.indexOf("名词")>=0||ttt.indexOf("论述")>=0||ttt.indexOf("写作")>=0||ttt.indexOf("未命名分区")>=0){
answer = $(questions[i]).find(".question-detail-solution").eq(1).find(".question-detail-solution-text").html()
console.log(title,answer)
ajax(title,answer)
continue;
}
var rightSelect = $(questions[i]).find(".question-detail-choice-solution").html()
if(ttt.indexOf("判断题")>=0){
rightSelect = $(questions[i]).find(".question-detail-choice-solution-text").eq(1).html()
ajax(title,rightSelect)
continue;
}
var options = $(questions[i]).find(".question-detail-options").find(".question-detail-option")
if(rightSelect.indexOf("A")>=0){
answer+=$(options[0]).find(".option-description-preview").html()+"#";
}
if(rightSelect.indexOf("B")>=0){
answer+=$(options[1]).find(".option-description-preview").html()+"#";
}
if(rightSelect.indexOf("C")>=0){
answer+=$(options[2]).find(".option-description-preview").html()+"#";
}
if(rightSelect.indexOf("D")>=0){
answer+=$(options[3]).find(".option-description-preview").html()+"#";
}
if(rightSelect.indexOf("E")>=0){
answer+=$(options[4]).find(".option-description-preview").html()+"#";
}
if(rightSelect.indexOf("F")>=0){
answer+=$(options[5]).find(".option-description-preview").html()+"#";
}
if(rightSelect.indexOf("G")>=0){
answer+=$(options[6]).find(".option-description-preview").html()+"#";
}
answer = answer.substring(0,answer.length-1)
ajax(title,answer)
}
},2000)
function ajax(title,anser){
if(title==""||anser==""){return}
var data = {
answer: anser,
title: title
};
var postDataStr = JSON.stringify(data);
GM_xmlhttpRequest({
//请求方式
method : "POST",
//请求的媒体类型
//contentType: "application/json;charset=UTF-8",
//请求地址
url : "http://q.api.fastk.cn/question/set",
// url : "http://127.0.0.1:8080/question/set",
data:postDataStr,
datatype: "json",
headers: {
"Content-type": "application/json;charset=UTF-8"
},
//请求成功
onload: res=> {},
//请求失败,包含具体的错误信息
error : function(e){
console.log(e.status);
console.log(e.responseText);
}
});
}
setTimeout(function(){
if(selfUrl.indexOf("ViewQuiz")>=0){return}
var questions = $(".question-detail-container")
for(var i=0;i标签
// 注意:这个正则表达式是简化的,可能无法处理所有复杂的HTML情况
const imgTagRegex = /
]*)>/g;
// 使用替换函数来修正标签
return htmlString.replace(imgTagRegex, (match, attributes) => {
// 如果标签没有以/>结束,则添加它
if (!match.endsWith('/>')) {
return `
`;
}
// 如果已经是正确的闭合标签,则保持不变
return match;
});
}
async function sss(question,i){
//var title = $(question).find(".question-detail-description").text().trim().replaceAll(" ","").replaceAll(" ","").replace(/\s+/g, "").replace(/\r?\n|\r/g, "")
var title = $(question).find(".detail-description-content").html().replace(" style=","style=").replace(/\r?\n|\r/g, "")
title = correctImgTagClosure(title)
console.log(title,"-----------")
var titleHtml = $(question).find(".question-detail-description").html();
var options = $(question).find(".question-detail-options").find(".question-detail-option")
var data = {
token: TOKEN,
title: title
};
var postDataStr = JSON.stringify(data);
GM_xmlhttpRequest({
//请求方式
method : "POST",
//请求的媒体类型
//contentType: "application/x-www-form-urlencoded",
//请求地址
url : "http://q.api.fastk.cn/question/getAnswer",
//url : "http://127.0.0.1:8080/question/getAnswer",
data:postDataStr,
//数据,json字符串
datatype: "json",
synchronous: true,
//请求成功
headers: {
"Content-type": "application/json;charset=UTF-8"
},
onload: res=> {
var result = JSON.parse(res.response)
console.log(result);
if(result.code==0){
var anser = result.data.answer
if(anser==null||anser==""){
for(var j=0;j=0||bigtitle.indexOf("填空")>=0||bigtitle.indexOf("简答")>=0||bigtitle.indexOf("写作")>=0){
$(question).find(".cke_wysiwyg_div").html(anser)
}
var ans = anser.split("#")
if($(question).find(".question-header-left").text().indexOf("判断题")>=0){
if("正确|对|True|T|√|true".indexOf(anser)>=0){
$(options[0]).find("input").click()
}
if("错误|错|Flase|F|×|false".indexOf(anser)>=0){
$(options[1]).find("input").click()
}
}else{
for(var j=0;j'+result.msg+''}else{as=''+result.data.answer+''}
var answerHtml = ' '
+' '+(Number(i)+1)+' | '
+' '+titleHtml+' | '
+' '+as+' | '
+'
';
$("#answerMain").append(answerHtml)
},
//请求失败,包含具体的错误信息
error : function(e){
console.log(e.status);
console.log(e.responseText);
}
});
console.log(title)
}
$("#saveToken").click(function(){
var kktoken = $("#kktoken").val()
localStorage.setItem("kktoken",kktoken)
layer.msg("保存成功")
})
// Your code here...
})();